home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / trubasic / rolldemos / demos / ip / shift_brownian.tru < prev   
Encoding:
Text File  |  1994-08-02  |  1.2 KB  |  43 lines

  1. ! File: BOX/Shift.Brownian
  2.  
  3. ! Uses a random walk to displace columns or rows by a defined offset
  4.  
  5. LIBRARY "IFFgl"       ! True BASIC for Silicon Graphics
  6. !LIBRARY ":LIB/IFF*",":LIB/Amiga*"
  7.  
  8. CALL IFFload(":IMAGES/Demo.Pic2",xmax,ymax,cmax)
  9. BOX KEEP 0,xmax,ymax,0 in screen$
  10.  
  11. CALL ColWalk(0,xmax,ymax,0,1,2)
  12. GET POINT: x,y
  13. BOX SHOW screen$ at 0,ymax
  14. CALL RowWalk(0,xmax,ymax,0,1,2)
  15. GET POINT: x,y
  16. BOX SHOW screen$ at 0,ymax
  17. CALL ColWalk(0,xmax,ymax,0,1,2)
  18. CALL RowWalk(0,xmax,ymax,0,1,2)
  19. get point x,y
  20. END
  21.  
  22. SUB ColWalk(lft,rgt,bas,top,colwid,yinc)
  23.     RANDOMIZE
  24.     LET drift= 0
  25.     FOR x= lft to rgt step colwid
  26.         LET drift= drift + (round(rnd)*2-1)*yinc      ! Drift + or -
  27.         BOX KEEP x,x+colwid-1,bas,top in col$         ! Fetch column
  28.         BOX SHOW col$ at x,bas+drift                  ! Replace with drift
  29.     NEXT x
  30. END SUB
  31.  
  32. SUB RowWalk(lft,rgt,bas,top,rowhgt,xinc)
  33.     RANDOMIZE
  34.     LET drift= 0
  35.     FOR y= top to bas step rowhgt
  36.         LET drift= drift + (round(rnd)*2-1)*xinc      ! Drift + or -
  37.         BOX KEEP lft,rgt,y+rowhgt-1,y in row$         ! Fetch row
  38.         BOX SHOW row$ at lft+drift,y                  ! Replace with drift
  39.     NEXT y
  40. END SUB
  41.  
  42.  
  43.